import type {
  CodeType,
  Patient,
  PatientList,
  User,
  UserInfo
} from '@/types/USer'
import { request } from '@/utils/request'
// 登录时候的请求
export const loginApi = (mobile: string, password: string) => {
  return request<User>('login/password', 'POST', { mobile, password })
}
// 验证码
export const sendMobileCodeApi = (mobile: string, type: CodeType) => {
  return request('code', 'GET', { mobile, type })
}
// 短信登录
export const sendCodeApi = (mobile: string, code: string) => {
  return request<User>('/login', 'post', { mobile, code })
}

// 用户
export const myUserApi = () => {
  return request<UserInfo>('/patient/myUser')
}
// 获患者信息列表
export const getPatientList = () => request<PatientList>('/patient/mylist')

//添加患者信息
export const AddPAtientApi = (Patient: Patient) =>
  request<PatientList>('/patient/add', 'POST', Patient)
// 编辑患者信息
export const editPatientApi = (patient: Patient) =>
  request('/patient/update', 'PUT', patient)

// 删除患者信息
export const delPatient = (id: string) =>
  request(`/patient/del/${id}`, 'DELETE')
// 查询患者详情
export const getPatientDetail = (id: string) =>
  request<Patient>(`/patient/info/${id}`)

export const getUnreadMessageCount = () =>
  request<number>('/patient/message/unRead/all')

//三方绑定手机号
export const bindMobile = (data: {
  mobile: string
  code: string
  openId: string
}) => request<User>('/login/binding', 'POST', data)
//通过qq进行登录
export const loginByQQ = (openId: string) =>
  request<User>('/login/thirdparty', 'POST', {
    openId,
    source: 'qq'
  })
